<!DOCTYPE html>
<html lang="zh-CN"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>积分列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/style/admin.css" media="all">
	<link rel="stylesheet" href="/style/list.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
				<div class="layui-inline">
                    <label class="layui-form-label">会员编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="userNo" id="userNo" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-input-inline" style="width:100px;">
                    <select name="state" id="state"  lay-verify="required" lay-filter="state" class="select" lay-verify="type">
                        <option value="-1">全部</option>
                        <option value="1">正常</option>
                        <option value="0">冻结</option>
                    </select>
                </div>
				<div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-search" onclick="SelectData()">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">

            <table class="layui-hide" id="test"></table>
			
			<script type="text/html" id="barBalance">
                {{d.state==1 ? d.balance:'<a class="layui-btn layui-btn-warm layui-btn-xs">冻结</a>'}}
            </script>

        </div>
    </div>
</div>
<script src="/layui/layui.js"></script>
<script src="/layui/jquery.min.js"></script>
<script src="/js/common.js"></script>
<script>
    var table;
    layui.use('table', function(){
        table = layui.table
            ,form = layui.form;

        var classify = $.getUrlParam("classify");

        table.render({
            elem: '#test'
            ,url:'/finace?url=Finace%2FList&classify='+classify
			,cellMinWidth:80
            ,cols: [[
                {type:'numbers'}
                ,{type: 'checkbox'}
                ,{field:'id', title:'ID'}
                ,{field:'userId', title:'编号ID' }
                ,{field:'userNo', title:'编号' }
				,{field:'amount', title:'金额'}
				,{field:'balance', title: '余额', templet: '#barBalance', unresize: true}
				,{field:'time',title: '时间'}
				,{field:'remark', title: '备注'}
				,{field:'uid', title: 'UID'}
				,{field:'aid', title: 'AID'}
            ]]
            ,page: true
            ,id: 'testReload'
        });

        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });


    });
	
    function SelectData() {
        //数据刷新
        var classify = $.getUrlParam("classify");
        var state = $('#state').val();
		var url="/finace?url=Finace%2FList&classify="+classify;
        if(usernoId!=-1)
        {
        	url+="&userId="+usernoId;
        }
        if(state!=null && state!="-1")
        {
            url+="&state="+state;
        }
		//alert(url);
        //执行重载
        table.reload('testReload', {
            url:url,
            page: {
                curr: 1 //重新从第 1 页开始
            }
        });
    }

    var usernoId=0;
    $("#userNo").blur(function () {
        var urls="/user?url=User%2FgetUserAndNoInfo&userNo="+$("#userNo").val();
        var url = "/wap/getUserAndNoInfo?userNoId="+$("#userNo").val();
        $.ajax({
            url: urls,
            type: "GET",
            async:false,
            dataType: "json", //指定服务器返回的数据类型
            success: function(result) {
                if(result.code=="000000"){
                    if(result.data!=null){
                        usernoId=result.data.id;
                    }else {
                        usernoId=-1;
                        alert("编号不存在!!");
                    }
                }
            }
        });
    });
	
</script>


</body>
</html>